home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / tex / mf / inputs / passaulogos / unilogos.mf < prev    next >
Text File  |  1994-06-09  |  11KB  |  365 lines

  1.  
  2. def SetZ( expr n, v ) =
  3.     x[n] := xpart(v);
  4.     y[n] := ypart(v);
  5.     enddef;
  6.  
  7. def OverwriteSystem   = true  enddef;
  8. def NoOverwriteSystem = false enddef;
  9.  
  10. numeric STD_INPUTSCALEX;  % Standard Eingabeskalierung in X-Richtung
  11. numeric STD_INPUTSCALEY;  % Standard Eingabeskalierung in Y-Richtung
  12. numeric STD_OUTPUTSCALEX; % Standard Ausgabeskalierung in X-Richtung
  13. numeric STD_OUTPUTSCALEY; % Standard Ausgabeskalierung in Y-Richtung
  14.  STD_INPUTSCALEX  = 1;
  15.  STD_INPUTSCALEY  = 1;
  16.  STD_OUTPUTSCALEX = 1;
  17.  STD_OUTPUTSCALEY = 1;
  18.  
  19.  
  20.  
  21. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  22. %%%
  23. %%% Datenstruktur der Koordinatensysteme als Stapel:
  24. %%%
  25. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26.  
  27.     %%% Der SystemStack wird in den Bereich der z-Variablen gelegt.
  28.     %%% Ein System besteht aus den folgenden Komponenten:
  29.  
  30.       %  - (2) pair    Nullpunkt
  31.       %  - (2) pair    Basisvektor1
  32.       %  - (1) numeric Eingabe-Streckungsfaktor Basisvektor1
  33.       %  - (1) numeric Ausgabe-Streckungsfaktor Basisvektor1
  34.       %  - (2) pair    Basisvektor2
  35.       %  - (1) numeric Eingabe-Streckungsfaktor Basisvektor2
  36.       %  - (1) numeric Ausgabe-Streckungsfaktor Basisvektor2
  37.       %  - (1) numeric Drehwinkel Basisvektor2
  38.       %  - (1) numeric Drehwinkel Basisvektor2
  39.       %    (6) Speicherplaetze in der Summe als Pair.
  40.  
  41.  
  42.     %%% Variablen:
  43.         numeric MAXSYSTEMS; % Maximale Zahl verschachtelter Systeme
  44.         numeric SYS_PAIRS; % Anzahl Speicherplaetze eines Systems
  45.         numeric SYS_STACKMIN; % Untere Grenze des SystemStacks
  46.         numeric SYS_STACKMAX; % Obere  Grenze des SystemStacks
  47.         numeric SYS_TOP; % Zeiger auf oberstes SystemStackElement
  48.         numeric SysRecDepth_Max;
  49.  numeric SysRecDepth_UserMaximal;
  50.  numeric SysRecDepth_UserActual;
  51.  
  52.         MAXSYSTEMS = 10;   % Maximal 10 Systeme verschachtelt.
  53.         SYS_PAIRS = 6;
  54.         SYS_STACKMIN = 0;    % SYS_STACK kommt zuerst im Speicher.
  55.  
  56.         % Platz fuer das Root-System muss reserviert werden:
  57.         SYS_STACKMAX = SYS_STACKMIN + ((MAXSYSTEMS+1) * SYS_PAIRS - 1);
  58.  
  59.  % SystemInformationen:
  60.  SysRecDepth_Max   = MAXSYSTEMS;
  61.  SysRecDepth_UserMaximal  = 0;
  62.  SysRecDepth_UserActual   = 0;
  63.  
  64.  
  65.     %%% Zugriffsoperationen:
  66.  
  67.  def Origin       = z[SYS_TOP+0] enddef;
  68.  def BaseX        = z[SYS_TOP+1] enddef;
  69.  def BaseY        = z[SYS_TOP+2] enddef;
  70.  def InputScaleX  = xpart(z[SYS_TOP+3]) enddef;
  71.  def InputScaleY  = ypart(z[SYS_TOP+3]) enddef;
  72.  def OutputScaleX = xpart(z[SYS_TOP+4]) enddef;
  73.  def OutputScaleY = ypart(z[SYS_TOP+4]) enddef;
  74.  def RotationX    = xpart(z[SYS_TOP+5]) enddef;
  75.  def RotationY    = ypart(z[SYS_TOP+5]) enddef;
  76.  def SystemDepth  = (SYS_TOP/SYS_PAIRS) enddef;
  77.  
  78.  def FatherOrigin       = z[SYS_TOP-SYS_PAIRS+0] enddef;
  79.  def FatherBaseX        = z[SYS_TOP-SYS_PAIRS+1] enddef;
  80.  def FatherBaseY        = z[SYS_TOP-SYS_PAIRS+2] enddef;
  81.  def FatherInputScaleX  = xpart(z[SYS_TOP-SYS_PAIRS+3]) enddef;
  82.  def FatherInputScaleY  = ypart(z[SYS_TOP-SYS_PAIRS+3]) enddef;
  83.  def FatherOutputScaleX = xpart(z[SYS_TOP-SYS_PAIRS+4]) enddef;
  84.  def FatherOutputScaleY = ypart(z[SYS_TOP-SYS_PAIRS+4]) enddef;
  85.  def FatherRotationX    = xpart(z[SYS_TOP-SYS_PAIRS+5]) enddef;
  86.  def FatherRotationY    = ypart(z[SYS_TOP-SYS_PAIRS+5]) enddef;
  87.  
  88.  def InitSystemStack =
  89.  
  90.      % Setzen des Root-Systemes, das nicht veraendert werden kann:
  91.        SetZ( SYS_STACKMIN+0, (0,0) );
  92.        SetZ( SYS_STACKMIN+1, (1,0) );
  93.        SetZ( SYS_STACKMIN+2, (0,1) );
  94.        SetZ( SYS_STACKMIN+3, (STD_INPUTSCALEX, STD_INPUTSCALEY ) );
  95.        SetZ( SYS_STACKMIN+4, (STD_OUTPUTSCALEX,STD_OUTPUTSCALEY) );
  96.        SetZ( SYS_STACKMIN+5, (0,0) );
  97.  
  98.      % Zeiger auf das oberste Stackelement wird auf das
  99.      % zweite Stackelement gesetzt, da das erste das
  100.      % Root-System ist und nicht geaendert werden darf:
  101.        SYS_TOP := SYS_STACKMIN + SYS_PAIRS;
  102.  
  103.      % Setzen des ersten Systemes auf Standard-Werte:
  104.        SetZ( SYS_STACKMIN+SYS_PAIRS+0, (0,0) );
  105.        SetZ( SYS_STACKMIN+SYS_PAIRS+1, (1,0) );
  106.        SetZ( SYS_STACKMIN+SYS_PAIRS+2, (0,1) );
  107.        SetZ( SYS_STACKMIN+SYS_PAIRS+3, ( CharWidth, CharHeight ) );
  108.        SetZ( SYS_STACKMIN+SYS_PAIRS+4, ( CharWidth, CharHeight ) );
  109.        SetZ( SYS_STACKMIN+SYS_PAIRS+5, (0,0) );
  110.  
  111.      % Anzeigen Stack-Groesse:
  112.      % showvariable MAXSYSTEMS;
  113.      enddef;
  114.  
  115.  
  116.  def CreateSystem( expr Null,
  117.           PInputScaleX, POutputScaleX, RotX,
  118.           PInputScaleY, POutputScaleY, RotY,
  119.           Overwrite
  120.    ) =
  121.  
  122.      % Aktuelles System soll nicht ueberschrieben werden? ->
  123.      % Erst ein neues Stapelelement erzeugen.
  124.      if not Overwrite:
  125.         SYS_TOP := SYS_TOP + SYS_PAIRS;
  126.         if ((SYS_TOP-SYS_STACKMIN)/SYS_PAIRS)-1
  127.               > SysRecDepth_UserMaximal:
  128.            SysRecDepth_UserMaximal := SYS_TOP-SYS_PAIRS
  129.         fi
  130.      fi;
  131.  
  132.      % Nullpunkt bzgl. Vatersystem berechnen und eintragen:
  133.      SetZ( SYS_TOP+0, FatherOrigin +
  134.             ( xpart(Null)/FatherInputScaleX*FatherOutputScaleX
  135.               *
  136.               FatherBaseX
  137.             )
  138.             +
  139.             ( ypart(Null)/FatherInputScaleY*FatherOutputScaleY
  140.               *
  141.               FatherBaseY
  142.             ) );
  143.  
  144.      % Basisvektor1: die Drehung wird zur Drehung des
  145.      % Vater-Basisvektors1 addiert.
  146.      SetZ( SYS_TOP+1, FatherBaseX rotated RotX );
  147.  
  148.      % Basisvektor2: die Drehung wird zur Drehung des
  149.      % Vater-Basisvektors2 addiert.
  150.      SetZ( SYS_TOP+2, FatherBaseY rotated RotY );
  151.  
  152.      SetZ( SYS_TOP+3, ( PInputScaleX, PInputScaleY ) );
  153.      SetZ( SYS_TOP+4,
  154.       ( (POutputScaleX/FatherInputScaleX)*CharWidth,
  155.         (POutputScaleY/FatherInputScaleY)*CharHeight
  156.       ) );
  157.  
  158.      % Rotationswinkel werden einfach addiert
  159.      % und nur der Genauigkeit wegen mit abgespeichert.
  160.      SetZ( SYS_TOP+5, ( RotX + FatherRotationX,
  161.             RotY + FatherRotationY  ) );
  162.  
  163.      enddef;
  164.  
  165.  
  166.  def PrintSystem =
  167.      pair    origin;
  168.      pair    x_base;
  169.      pair    y_base;
  170.      numeric x_inputscale;
  171.      numeric y_inputscale;
  172.      numeric x_outputscale;
  173.      numeric y_outputscale;
  174.      numeric x_rotation;
  175.      numeric y_rotation;
  176.      numeric system_nesting_deepness;
  177.  
  178.      system_nesting_deepness = SystemDepth;
  179.      origin        = Origin;
  180.      x_base        = BaseX;
  181.      y_base        = BaseY;
  182.      x_inputscale  := InputScaleX;
  183.      y_inputscale  := InputScaleY;
  184.      x_outputscale := OutputScaleX;
  185.      y_outputscale := OutputScaleY;
  186.      x_rotation    := RotationX;
  187.      y_rotation    := RotationY;
  188.  
  189.      show " ##### datas of the actual system:";
  190.      showvariable system_nesting_deepness;
  191.      showvariable origin;
  192.      showvariable x_base;
  193.      showvariable x_inputscale;
  194.      showvariable x_outputscale;
  195.      showvariable x_rotation;
  196.      showvariable y_base;
  197.      showvariable y_inputscale;
  198.      showvariable y_outputscale;
  199.      showvariable y_rotation;
  200.  
  201.      enddef;
  202.  
  203.  
  204.  def ChangeSystem( expr Null,
  205.           InputScaleX, OutputScaleX, RotX,
  206.           InputScaleY, OutputScaleY, RotY
  207.    ) =
  208.        CreateSystem( Null,
  209.      InputScaleX, OutputScaleX, RotX,
  210.      InputScaleY, OutputScaleY, RotY,
  211.      OverwriteSystem
  212.    )
  213.      enddef;
  214.  
  215.  
  216.  def EnterSystem( expr Null,
  217.          InputScaleX, OutputScaleX, RotX,
  218.          InputScaleY, OutputScaleY, RotY
  219.    ) =
  220.      if SYS_TOP + SYS_PAIRS < SYS_STACKMAX:
  221.         CreateSystem( Null,
  222.         InputScaleX, OutputScaleX, RotX,
  223.         InputScaleY, OutputScaleY, RotY,
  224.         NoOverwriteSystem
  225.       )
  226. %     else:
  227. %        show " ";
  228. %        show " System-Stack-Overflow: (EnterSystem) ";
  229. %        show " Your systems are too deeply nested!";
  230. %        show " If you really want to nest your systems deeper, ";
  231. %        show " then you should enlarge the SystemStack: ";
  232. %        showvariable MAXSYSTEMS;
  233. %        errmessage "Sorry";
  234.      fi;
  235.      enddef;
  236.  
  237.  
  238.  def LeaveSystem =
  239.      if SYS_TOP > (SYS_STACKMIN + SYS_PAIRS):
  240.         SYS_TOP := SYS_TOP - SYS_PAIRS;
  241.      else:
  242.         show " ";
  243.         show " System-Stack-Underflow: (LeaveSystem) ";
  244.         show "    There is no more System to leave! ";
  245.         errmessage "Sorry";
  246.      fi;
  247.      enddef;
  248.  
  249.  
  250.  def CopySystem =
  251.      EnterSystem( (0,0), InputScaleX, InputScaleX, 0,
  252.            InputScaleY, InputScaleY, 0
  253.    )
  254.      enddef;
  255.  
  256.  
  257.  def MoveSystem( expr xp, yp ) =
  258.      SetZ( SYS_TOP+0, z[SYS_TOP+0]
  259.             + (xp/InputScaleX*OutputScaleX*BaseX)
  260.             + (yp/InputScaleY*OutputScaleY*BaseY) )
  261.      enddef;
  262.  
  263.  
  264.  def ScaleSystem( expr xp, yp ) =
  265.      SetZ( SYS_TOP+4, (xp*x[SYS_TOP+4], yp*y[SYS_TOP+4]) )
  266.      enddef;
  267.  
  268.  
  269.  def SetInputScale( expr xp, yp ) =
  270.      SetZ( SYS_TOP+3, (xp, yp) )
  271.      enddef;
  272.  
  273.  
  274.  def SetOutputScale( expr xp, yp ) =
  275.      SetZ( SYS_TOP+4, (xp*FatherOutputScaleX, yp*FatherOutputScaleY) )
  276.      enddef;
  277.  
  278.  
  279.  def RotateSystem( expr xp, yp ) =
  280.      SetZ( SYS_TOP+5, (xp+x[SYS_TOP+5], yp+y[SYS_TOP+5]) );
  281.      SetZ( SYS_TOP+1, FatherBaseX rotated RotationX );
  282.      SetZ( SYS_TOP+2, FatherBaseY rotated RotationY );
  283.      enddef;
  284.  
  285.  
  286.  
  287. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  288. %%%
  289. %%% Datenstruktur der Punkte (Koordinatenpaare) als Stapel:
  290. %%%
  291. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  292.  
  293.     %%% Variablen:
  294.         numeric POINT_STACKMIN; % Untere Grenze des PunkteStacks
  295.         numeric POINT_TOP; % Zeiger auf oberstes PunkteStackElement
  296.  
  297.     %%% SystemInformationen:
  298.  numeric UserPoints;
  299.  UserPoints = 0;
  300.  
  301.  
  302.  def InitPointStack =
  303.      POINT_STACKMIN = SYS_STACKMAX + 1;
  304.      POINT_TOP    = POINT_STACKMIN;
  305.      enddef;
  306.  
  307.  def point( expr pp ) =
  308.          x[POINT_TOP] := xpart(pp);
  309.          y[POINT_TOP] := ypart(pp);
  310.      POINT_TOP := POINT_TOP + 1;
  311.      UserPoints := UserPoints+1;
  312.      enddef;
  313.  
  314.  def thelastpoint = POINT_TOP-1 enddef;
  315.  def thenextpoint = POINT_TOP   enddef;
  316.  
  317.  def next( expr p, n ) =
  318.      Origin + ((x[p+n]/InputScaleX)*OutputScaleX)*BaseX
  319.          + ((y[p+n]/InputScaleY)*OutputScaleY)*BaseY
  320.      enddef;
  321.  
  322.  def thepoint( expr p ) = next( p, 0 );
  323.      enddef;
  324.  
  325.  def last( expr n ) =
  326.      Origin + ((x[POINT_TOP-1-n]/InputScaleX)*OutputScaleX)*BaseX
  327.          + ((y[POINT_TOP-1-n]/InputScaleY)*OutputScaleY)*BaseY
  328.      enddef;
  329.  
  330.  def this( expr px, py ) =
  331.      Origin + ((px/InputScaleX)*OutputScaleX)*BaseX
  332.          + ((py/InputScaleY)*OutputScaleY)*BaseY
  333.      enddef;
  334.  
  335.  def tan( expr px, py ) =
  336.      ((px/InputScaleX)*OutputScaleX)*BaseX +
  337.      ((py/InputScaleY)*OutputScaleY)*BaseY
  338.      enddef;
  339.  
  340.  
  341. def SystemInfo =
  342.     show "### SystemInfo:";
  343.     SysRecDepth_UserActual := (SYS_TOP/SYS_PAIRS)-1;
  344.     showvariable SysRecDepth_Max;
  345.     showvariable SysRecDepth_UserMaximal;
  346.     showvariable SysRecDepth_UserActual;
  347.     showvariable UserPoints;
  348.     show "";
  349.     enddef;
  350.  
  351. def ShowSystem =
  352.     pickup pencircle;
  353.     draw this( 0,0 )--
  354.       this( InputScaleX,0 )--
  355.       this( InputScaleX,InputScaleY )--
  356.       this( 0,InputScaleY )--cycle;
  357.     enddef;
  358.  
  359. def InitSystems =
  360.     InitSystemStack;
  361.     InitPointStack
  362.     enddef;
  363.  
  364. InitSystems;
  365.